<?php
require_once('global.php');

$tid = intval($tid);
$cid = intval($cid);

unset($_GET,$_POST,$_REQUEST);
$jumpurl = '';
require_once(D_P.'data/cache/cate_'.$cid.'.php');
if($job == 'next'){
	$rs = $db->get_one("SELECT tid,cid,url FROM cms_contentindex WHERE cid='$cid' AND tid>'$tid' AND ifpub=1 ORDER BY tid ASC LIMIT 1");
	if(!$rs){
		echo "<script language=\"javascript\">\n";
		echo "alert(\"已经是最后一篇文章\");\n";
		echo "window.history.go(-1);\n";
		echo "</script>";
		exit;
	}elseif ($rs['url'] && $cateInfo['htmlpub']){
		$jumpurl = $very['htmdir']."/".$rs['url'];
	}else{
		$jumpurl = "view.php?tid=".$rs['tid']."&cid=".$rs['cid'];
	}
}elseif ($job == 'pre'){
	$rs = $db->get_one("SELECT tid,cid,url FROM cms_contentindex WHERE cid='$cid' AND tid<'$tid' AND ifpub=1 ORDER BY tid DESC LIMIT 1");
	if(!$rs){
		echo "<script language=\"javascript\">\n";
		echo "alert(\"已经是第一篇文章\");\n";
		echo "window.history.go(-1);\n";
		echo "</script>";
		exit;	
	}elseif ($rs['url'] && $cateInfo['htmlpub']){
		$jumpurl = $very['htmdir']."/".$rs['url'];
	}else{
		$jumpurl = "view.php?tid=".$rs['tid']."&cid=".$rs['cid'];
	}
}
ObHeader($jumpurl);
exit;
?>